<?php
class AppController extends Controller
{
	var $helpers = array('Javascript', 'Form', 'Session');

    function beforeFilter()
    {
        $this->loadModel("Ban");
        if($this->Ban->isBanned()) {
            $this->header('HTTP/1.1 403 Forbidden');
            die();
        }

        //check if photoalbum file is outdated
        App::import('Xml');
        $this->loadModel("Photoalbum");
        $this->Photoalbum->checkOutdated();
    }

	function beforeRender()
	{
		//get menu data
        $this->loadModel("Content");
		$this->set('menu_data', $this->Content->getMenuitems());
        //get content
        $this->set('content', $this->Content->getContent($this->params['url']['url']));
		
		//set photos
		$this->set('newAlbums', $this->Photoalbum->getNewest(3));
		
		//set top attendances
		$this->loadModel('Attendance');
		$this->set('topAttendances', $this->Attendance->getTopAttendances(3));
		
		//set the matches
		$this->loadModel('Match');
		$this->set('upcomingMatches', $this->Match->getUpcoming());
		$this->set('playedMatches', $this->Match->getPlayed());
	}
}
